package memorphic.slide
{
	
	public class TriggerInfo
	{
		
		private var typeDescription:XML;
		
		private var cachedTriggers:Array;
		
		
		public function get numProps():uint
		{
			return getTriggers().length;
		}
		
		public function TriggerInfo(typeDescription:XML)
		{
			this.typeDescription = typeDescription;
		}

		public function getTriggers():Array
		{
			if(!cachedTriggers){
				cachedTriggers = new Array();
				
				var isSetter:Boolean = false;
				var uri:String;
				var meta:XMLList = (typeDescription.accessor + typeDescription.method).metadata.(@name == "Trigger");
				if(meta.length() > 0){
					for each(var m:XML in meta){
						var node:XML = m.parent() as XML;
						isSetter = node.name() == "accessor";
						// TODO: check that it is actually a writable property if it's an accessor
						//cachedPropNames[node.@name] = true;
						cachedTriggers.push(new TriggerInfoItem(node.@name, node.@uri, isSetter, m));
					}
				}
			}
			
			return cachedTriggers;
		}
	
	}
}

